//
//  InfoFeedBackViewController.m
//  ShoppingExperience
//
//  Created by LiYinDi on 15/11/16.
//  Copyright © 2015年 RuiBen. All rights reserved.
//

#import "InfoFeedBackViewController.h"

@interface InfoFeedBackViewController ()

@end

@implementation InfoFeedBackViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _feedbackTextView.layer.borderColor=[[UIColor colorWithRed:239.0f/255.0f green:239.0f/255.0f blue:239.0f/255.0f alpha:1] CGColor];
    _feedbackTextView.layer.borderWidth= 1.0f;
    _feedbackTextView.layer.cornerRadius=3;
    

    [_infoFeedbackAlphaView setBackgroundColor:[Global parseColor:WESTORE_TRANSCLUCENT]];
    [_infoFeedbackAlphaView addTarget:self action:@selector(infoFeedBackAlphaViewClick) forControlEvents:UIControlEventTouchUpInside];
}
-(void)infoFeedBackAlphaViewClick
{
    if (self.view!=nil) {
        [self.view removeFromSuperview];
        [self removeFromParentViewController];
        
    }
    

}
-(IBAction)submitFeedBack:(id)sender
{
    if ([Global getLoginToken].length!=0)
    {
        [Global showIndeterminateHud:@"请稍后。。。" delay:30 view:self.view];
        NSMutableDictionary *params=[[NSMutableDictionary alloc] init];
        [params setObject:_feedbackTextView.text forKey:@"Content"];
        [params setObject:[Global getLoginToken] forKey:@"Token"];
        //   NSLog(@"parr===%@",params);
        [HttpRequest requestData:@"ShopManager/FeedBack" params:params success:^(BOOL isSuccess, SeverData *severDataDict) {
            if (isSuccess) {
                // NSLog(@"severddd===%@",severDataDict.dataDict);
                // [Global hideProgressHUDInternal:self.view];
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    // [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                    if (self.view!=nil) {
                        [self.view removeFromSuperview];
                        [self removeFromParentViewController];
                        
                    }

                }
                else
                {
                    // NSLog(@"loginnnnnnnnn");
                    [Global hideProgressHUDInternal:self.view];
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    // [Global showTextHud:requestResultStr view:self.view];
                    [Global showTextHudSub:requestResultStr view:self.view];
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                        
                        [Global loginViewController:self noteStr:requestResultStr];
                        //  [Global loginViewController:self];
                    }
                    
                }
            }
            else
            {
                [Global hideProgressHUDInternal:self.view];
                [Global showTextHudSub:@"连接失败" view:self.view];
                
            }
        }];
    }
}

- (void)textViewDidChange:(UITextView *)textView
{
    if (textView==_feedbackTextView) {
        if (textView.text.length == 0) {
            _feedbackTextViewImage.hidden=NO;
            _feedbackTextViewLabel.hidden=NO;
        }
        else
        {
            _feedbackTextViewImage.hidden=YES;
            _feedbackTextViewLabel.hidden=YES;
            
        }
        
    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
